﻿package treatBehavior
{
	public class FilterBehavior implements ITreatBehavior
	{
	                                    //================ Constants ===================
	                                    //================ Constructor =================	                                
		public function FilterBehavior(aVal:Array,dVal:Number,nVal:uint):void
		{
			arr=aVal;
			d=dVal;
			n=nVal;
			init();
		}
										//================ Valuables ===================
		private var arr:Array;
		private var d:Number;
		private var n:uint;
	                                    //================ Properties ==================

										//------------------------------
										//		abc
										//------------------------------
	
										//================ Public Methods ==============
		public function getTreatArr():Array
		{
			var secondPoint=0;
			var firstPoint=n;
			while(firstPoint<arr.length-1)
			{			
				var tempNumX:Number=arr[firstPoint].x-arr[secondPoint].x;
				var tempNumY:Number=arr[firstPoint].y-arr[secondPoint].y;
				var distance:Number=Math.pow((tempNumX*tempNumX+tempNumY*tempNumY),.5);
				if(distance < d)
				{	arr.splice(firstPoint,1);
				}
				else
				{	firstPoint++;
					secondPoint++;
				}
			}
			return arr;
		}
										//================ Private Methods =============
		private function init():void
		{		
		}
										//================ Destroy =====================
	}
}